package com.lg.data.singleton;

/**
 * volatile 的最佳实践，关于 double check locking
 *
 * @author by Mr. Li 2021/3/19 13:08
 */
public class DCL {

    private volatile static DCL install;

    private DCL() {
    }

    // 双重检查
    public static DCL getInstall() {
        if (install == null) {
            synchronized (DCL.class) {
                if (install == null) {
                    return install = new DCL();
                }
            }
        }
        return install;
    }
}
